<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: event-valuechange   event-valuechange.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
	<link rel="stylesheet" type="text/css" href="assets/api.css" />

    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
        <h3>event-valuechange&nbsp; <span class="subtitle">3.3.0</span></h3>
        <a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a> 
            &gt; <a href="./module_event-valuechange.html" title="event-valuechange">event-valuechange</a>
                
                 &gt; event-valuechange.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
                        <div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * Adds a synthetic &lt;code&gt;valueChange&lt;/code&gt; event that fires when the</span>
<span class="cm"> * &lt;code&gt;value&lt;/code&gt; property of an input field or textarea changes as a result</span>
<span class="cm"> * of a keystroke, mouse operation, or input method editor (IME) input event.</span>
<span class="cm"> *</span>
<span class="cm"> * @module event-valuechange</span>
<span class="cm"> */</span>

<span class="cm">/**</span>
<span class="cm"> * Provides the implementation for the synthetic &lt;code&gt;valueChange&lt;/code&gt; event.</span>
<span class="cm"> *</span>
<span class="cm"> * @class ValueChange</span>
<span class="cm"> * @static</span>
<span class="cm"> */</span>

<span class="kd">var</span> <span class="nx">YArray</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nb">Array</span><span class="p">,</span>

    <span class="nx">VALUE</span> <span class="o">=</span> <span class="s1">&#39;value&#39;</span><span class="p">,</span>

<span class="c1">// Just a simple namespace to make methods overridable.</span>
<span class="nx">VC</span> <span class="o">=</span> <span class="p">{</span>
    <span class="c1">// -- Static Constants -----------------------------------------------------</span>

    <span class="cm">/**</span>
<span class="cm">     * Interval (in milliseconds) at which to poll for changes to the value of</span>
<span class="cm">     * an element with one or more &lt;code&gt;valueChange&lt;/code&gt; subscribers when the</span>
<span class="cm">     * user is likely to be interacting with it.</span>
<span class="cm">     *</span>
<span class="cm">     * @property POLL_INTERVAL</span>
<span class="cm">     * @type Number</span>
<span class="cm">     * @default 50</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">POLL_INTERVAL</span><span class="o">:</span> <span class="mi">50</span><span class="p">,</span>

    <span class="cm">/**</span>
<span class="cm">     * Timeout (in milliseconds) after which to stop polling when there hasn&#39;t</span>
<span class="cm">     * been any new activity (keypresses, mouse clicks, etc.) on an element.</span>
<span class="cm">     *</span>
<span class="cm">     * @property TIMEOUT</span>
<span class="cm">     * @type Number</span>
<span class="cm">     * @default 10000</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">TIMEOUT</span><span class="o">:</span> <span class="mi">10000</span><span class="p">,</span>

    <span class="c1">// -- Protected Static Properties ------------------------------------------</span>
    <span class="nx">_history</span>  <span class="o">:</span> <span class="p">{},</span>
    <span class="nx">_intervals</span><span class="o">:</span> <span class="p">{},</span>
    <span class="nx">_notifiers</span><span class="o">:</span> <span class="p">{},</span>
    <span class="nx">_timeouts</span> <span class="o">:</span> <span class="p">{},</span>

    <span class="c1">// -- Protected Static Methods ---------------------------------------------</span>

    <span class="cm">/**</span>
<span class="cm">     * Called at an interval to poll for changes to the value of the specified</span>
<span class="cm">     * node.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _poll</span>
<span class="cm">     * @param {Node} node</span>
<span class="cm">     * @param {String} stamp</span>
<span class="cm">     * @param {EventFacade} e</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_poll</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">,</span> <span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">domNode</span> <span class="o">=</span> <span class="nx">node</span><span class="p">.</span><span class="nx">_node</span><span class="p">,</span> <span class="c1">// performance cheat; getValue() is a big hit when polling</span>
            <span class="nx">newVal</span>  <span class="o">=</span> <span class="nx">domNode</span> <span class="o">&amp;&amp;</span> <span class="nx">domNode</span><span class="p">.</span><span class="nx">value</span><span class="p">,</span>
            <span class="nx">prevVal</span> <span class="o">=</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_history</span><span class="p">[</span><span class="nx">stamp</span><span class="p">],</span>
            <span class="nx">facade</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">domNode</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;_poll: node &#39;</span> <span class="o">+</span> <span class="nx">stamp</span> <span class="o">+</span> <span class="s1">&#39; disappeared; stopping polling.&#39;</span><span class="p">,</span> <span class="s1">&#39;warn&#39;</span><span class="p">,</span> <span class="s1">&#39;event-valuechange&#39;</span><span class="p">);</span>
            <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopPolling</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span>
            <span class="k">return</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">newVal</span> <span class="o">!==</span> <span class="nx">prevVal</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">VC</span><span class="p">.</span><span class="nx">_history</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">newVal</span><span class="p">;</span>

            <span class="nx">facade</span> <span class="o">=</span> <span class="p">{</span>
                <span class="nx">_event</span> <span class="o">:</span> <span class="nx">e</span><span class="p">,</span>
                <span class="nx">newVal</span> <span class="o">:</span> <span class="nx">newVal</span><span class="p">,</span>
                <span class="nx">prevVal</span><span class="o">:</span> <span class="nx">prevVal</span>
            <span class="p">};</span>

            <span class="nx">YArray</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="nx">VC</span><span class="p">.</span><span class="nx">_notifiers</span><span class="p">[</span><span class="nx">stamp</span><span class="p">],</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">notifier</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">notifier</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="nx">facade</span><span class="p">);</span>
            <span class="p">});</span>

            <span class="nx">VC</span><span class="p">.</span><span class="nx">_refreshTimeout</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Restarts the inactivity timeout for the specified node.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _refreshTimeout</span>
<span class="cm">     * @param {Node} node</span>
<span class="cm">     * @param {String} stamp</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_refreshTimeout</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopTimeout</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span> <span class="c1">// avoid dupes</span>

        <span class="c1">// If we don&#39;t see any changes within the timeout period (10 seconds by</span>
        <span class="c1">// default), stop polling.</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_timeouts</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
            <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopPolling</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span>
        <span class="p">},</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">TIMEOUT</span><span class="p">);</span>

        <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;_refreshTimeout: &#39;</span> <span class="o">+</span> <span class="nx">stamp</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;event-valuechange&#39;</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Begins polling for changes to the &lt;code&gt;value&lt;/code&gt; property of the</span>
<span class="cm">     * specified node. If polling is already underway for the specified node,</span>
<span class="cm">     * it will not be restarted unless the &lt;i&gt;force&lt;/i&gt; parameter is</span>
<span class="cm">     * &lt;code&gt;true&lt;/code&gt;</span>
<span class="cm">     *</span>
<span class="cm">     * @method _startPolling</span>
<span class="cm">     * @param {Node} node Node to watch.</span>
<span class="cm">     * @param {String} stamp (optional) Object stamp for the node. Will be</span>
<span class="cm">     *   generated if not provided (provide it to improve performance).</span>
<span class="cm">     * @param {EventFacade} e (optional) Event facade of the event that</span>
<span class="cm">     *   initiated the polling (if any).</span>
<span class="cm">     * @param {Boolean} force (optional) If &lt;code&gt;true&lt;/code&gt;, polling will be</span>
<span class="cm">     *   restarted even if we&#39;re already polling this node.</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_startPolling</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">,</span> <span class="nx">e</span><span class="p">,</span> <span class="nx">force</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">stamp</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">stamp</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">stamp</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// Don&#39;t bother continuing if we&#39;re already polling.</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">force</span> <span class="o">&amp;&amp;</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_intervals</span><span class="p">[</span><span class="nx">stamp</span><span class="p">])</span> <span class="p">{</span>
            <span class="k">return</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopPolling</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span> <span class="c1">// avoid dupes</span>

        <span class="c1">// Poll for changes to the node&#39;s value. We can&#39;t rely on keyboard</span>
        <span class="c1">// events for this, since the value may change due to a mouse-initiated</span>
        <span class="c1">// paste event, an IME input event, or for some other reason that</span>
        <span class="c1">// doesn&#39;t trigger a key event.</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_intervals</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">setInterval</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
            <span class="nx">VC</span><span class="p">.</span><span class="nx">_poll</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
        <span class="p">},</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">POLL_INTERVAL</span><span class="p">);</span>

        <span class="nx">VC</span><span class="p">.</span><span class="nx">_refreshTimeout</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>

        <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;_startPolling: &#39;</span> <span class="o">+</span> <span class="nx">stamp</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;event-valuechange&#39;</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Stops polling for changes to the specified node&#39;s &lt;code&gt;value&lt;/code&gt;</span>
<span class="cm">     * attribute.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _stopPolling</span>
<span class="cm">     * @param {Node} node</span>
<span class="cm">     * @param {String} stamp (optional)</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_stopPolling</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">stamp</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">stamp</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">stamp</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="nx">VC</span><span class="p">.</span><span class="nx">_intervals</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">clearInterval</span><span class="p">(</span><span class="nx">VC</span><span class="p">.</span><span class="nx">_intervals</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]);</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopTimeout</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span>

        <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;_stopPolling: &#39;</span> <span class="o">+</span> <span class="nx">stamp</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;event-valuechange&#39;</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Clears the inactivity timeout for the specified node, if any.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _stopTimeout</span>
<span class="cm">     * @param {Node} node</span>
<span class="cm">     * @param {String} stamp (optional)</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_stopTimeout</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">stamp</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">stamp</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">stamp</span><span class="p">(</span><span class="nx">node</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="nx">VC</span><span class="p">.</span><span class="nx">_timeouts</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">clearTimeout</span><span class="p">(</span><span class="nx">VC</span><span class="p">.</span><span class="nx">_timeouts</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]);</span>
    <span class="p">},</span>

    <span class="c1">// -- Protected Static Event Handlers --------------------------------------</span>

    <span class="cm">/**</span>
<span class="cm">     * Stops polling when a node&#39;s blur event fires.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onBlur</span>
<span class="cm">     * @param {EventFacade} e</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onBlur</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopPolling</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">currentTarget</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Resets a node&#39;s history and starts polling when a focus event occurs.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onFocus</span>
<span class="cm">     * @param {EventFacade} e</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onFocus</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">node</span> <span class="o">=</span> <span class="nx">e</span><span class="p">.</span><span class="nx">currentTarget</span><span class="p">;</span>

        <span class="nx">VC</span><span class="p">.</span><span class="nx">_history</span><span class="p">[</span><span class="nx">Y</span><span class="p">.</span><span class="nx">stamp</span><span class="p">(</span><span class="nx">node</span><span class="p">)]</span> <span class="o">=</span> <span class="nx">node</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="nx">VALUE</span><span class="p">);</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_startPolling</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Starts polling when a node receives a keyDown event.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onKeyDown</span>
<span class="cm">     * @param {EventFacade} e</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onKeyDown</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_startPolling</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">currentTarget</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Starts polling when an IME-related keyUp event occurs on a node.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onKeyUp</span>
<span class="cm">     * @param {EventFacade} e</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onKeyUp</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// These charCodes indicate that an IME has started. We&#39;ll restart</span>
        <span class="c1">// polling and give the IME up to 10 seconds (by default) to finish.</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">charCode</span> <span class="o">===</span> <span class="mi">229</span> <span class="o">||</span> <span class="nx">e</span><span class="p">.</span><span class="nx">charCode</span> <span class="o">===</span> <span class="mi">197</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">VC</span><span class="p">.</span><span class="nx">_startPolling</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">currentTarget</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">e</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Starts polling when a node receives a mouseDown event.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onMouseDown</span>
<span class="cm">     * @param {EventFacade} e</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onMouseDown</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">VC</span><span class="p">.</span><span class="nx">_startPolling</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">currentTarget</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">e</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Called when event-valuechange receives a new subscriber.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onSubscribe</span>
<span class="cm">     * @param {Node} node</span>
<span class="cm">     * @param {Subscription} subscription</span>
<span class="cm">     * @param {SyntheticEvent.Notifier} notifier</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onSubscribe</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">subscription</span><span class="p">,</span> <span class="nx">notifier</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">stamp</span>     <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">stamp</span><span class="p">(</span><span class="nx">node</span><span class="p">),</span>
            <span class="nx">notifiers</span> <span class="o">=</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_notifiers</span><span class="p">[</span><span class="nx">stamp</span><span class="p">];</span>

        <span class="nx">VC</span><span class="p">.</span><span class="nx">_history</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">node</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="nx">VALUE</span><span class="p">);</span>

        <span class="nx">notifier</span><span class="p">.</span><span class="nx">_handles</span> <span class="o">=</span> <span class="nx">node</span><span class="p">.</span><span class="nx">on</span><span class="p">({</span>
            <span class="nx">blur</span>     <span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onBlur</span><span class="p">,</span>
            <span class="nx">focus</span>    <span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onFocus</span><span class="p">,</span>
            <span class="nx">keydown</span>  <span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onKeyDown</span><span class="p">,</span>
            <span class="nx">keyup</span>    <span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onKeyUp</span><span class="p">,</span>
            <span class="nx">mousedown</span><span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onMouseDown</span>
        <span class="p">});</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">notifiers</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">notifiers</span> <span class="o">=</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_notifiers</span><span class="p">[</span><span class="nx">stamp</span><span class="p">]</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="p">}</span>

        <span class="nx">notifiers</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">notifier</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Called when event-valuechange loses a subscriber.</span>
<span class="cm">     *</span>
<span class="cm">     * @method _onUnsubscribe</span>
<span class="cm">     * @param {Node} node</span>
<span class="cm">     * @param {Subscription} subscription</span>
<span class="cm">     * @param {SyntheticEvent.Notifier} notifier</span>
<span class="cm">     * @protected</span>
<span class="cm">     * @static</span>
<span class="cm">     */</span>
    <span class="nx">_onUnsubscribe</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">subscription</span><span class="p">,</span> <span class="nx">notifier</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">stamp</span>     <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">stamp</span><span class="p">(</span><span class="nx">node</span><span class="p">),</span>
            <span class="nx">notifiers</span> <span class="o">=</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_notifiers</span><span class="p">[</span><span class="nx">stamp</span><span class="p">],</span>
            <span class="nx">index</span>     <span class="o">=</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">notifiers</span><span class="p">,</span> <span class="nx">notifier</span><span class="p">);</span>

        <span class="nx">notifier</span><span class="p">.</span><span class="nx">_handles</span><span class="p">.</span><span class="nx">detach</span><span class="p">();</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">index</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">notifiers</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">index</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>

            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">notifiers</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">VC</span><span class="p">.</span><span class="nx">_stopPolling</span><span class="p">(</span><span class="nx">node</span><span class="p">,</span> <span class="nx">stamp</span><span class="p">);</span>

                <span class="k">delete</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_notifiers</span><span class="p">[</span><span class="nx">stamp</span><span class="p">];</span>
                <span class="k">delete</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_history</span><span class="p">[</span><span class="nx">stamp</span><span class="p">];</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">};</span>

<span class="cm">/**</span>
<span class="cm"> * &lt;p&gt;</span>
<span class="cm"> * Synthetic event that fires when the &lt;code&gt;value&lt;/code&gt; property of an input</span>
<span class="cm"> * field or textarea changes as a result of a keystroke, mouse operation, or</span>
<span class="cm"> * input method editor (IME) input event.</span>
<span class="cm"> * &lt;/p&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;p&gt;</span>
<span class="cm"> * Unlike the &lt;code&gt;onchange&lt;/code&gt; event, this event fires when the value</span>
<span class="cm"> * actually changes and not when the element loses focus. This event also</span>
<span class="cm"> * reports IME and multi-stroke input more reliably than &lt;code&gt;oninput&lt;/code&gt; or</span>
<span class="cm"> * the various key events across browsers.</span>
<span class="cm"> * &lt;/p&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;p&gt;</span>
<span class="cm"> * This event is provided by the &lt;code&gt;event-valuechange&lt;/code&gt; module.</span>
<span class="cm"> * &lt;/p&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;p&gt;</span>
<span class="cm"> * &lt;strong&gt;Usage example:&lt;/strong&gt;</span>
<span class="cm"> * &lt;/p&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;code&gt;&lt;pre&gt;</span>
<span class="cm"> * YUI().use(&#39;event-valuechange&#39;, function (Y) {</span>
<span class="cm"> * &amp;nbsp;&amp;nbsp;Y.one(&#39;input&#39;).on(&#39;valueChange&#39;, function (e) {</span>
<span class="cm"> * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Handle valueChange events on the first input element on the page.</span>
<span class="cm"> * &amp;nbsp;&amp;nbsp;});</span>
<span class="cm"> * });</span>
<span class="cm"> * &lt;/pre&gt;&lt;/code&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * @event valueChange</span>
<span class="cm"> * @param {EventFacade} e Event facade with the following additional</span>
<span class="cm"> *   properties:</span>
<span class="cm"> *</span>
<span class="cm"> * &lt;dl&gt;</span>
<span class="cm"> *   &lt;dt&gt;prevVal (String)&lt;/dt&gt;</span>
<span class="cm"> *   &lt;dd&gt;</span>
<span class="cm"> *     Previous value before the latest change.</span>
<span class="cm"> *   &lt;/dd&gt;</span>
<span class="cm"> *</span>
<span class="cm"> *   &lt;dt&gt;newVal (String)&lt;/dt&gt;</span>
<span class="cm"> *   &lt;dd&gt;</span>
<span class="cm"> *     New value after the latest change.</span>
<span class="cm"> *   &lt;/dd&gt;</span>
<span class="cm"> * &lt;/dl&gt;</span>
<span class="cm"> *</span>
<span class="cm"> * @for YUI</span>
<span class="cm"> */</span>

<span class="nx">Y</span><span class="p">.</span><span class="nx">Event</span><span class="p">.</span><span class="nx">define</span><span class="p">(</span><span class="s1">&#39;valueChange&#39;</span><span class="p">,</span> <span class="p">{</span>
    <span class="nx">detach</span><span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onUnsubscribe</span><span class="p">,</span>
    <span class="nx">on</span>    <span class="o">:</span> <span class="nx">VC</span><span class="p">.</span><span class="nx">_onSubscribe</span><span class="p">,</span>

    <span class="nx">publishConfig</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">emitFacade</span><span class="o">:</span> <span class="kc">true</span>
    <span class="p">}</span>
<span class="p">});</span>

<span class="nx">Y</span><span class="p">.</span><span class="nx">ValueChange</span> <span class="o">=</span> <span class="nx">VC</span><span class="p">;</span>
</pre></div>

                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class=""><a href="module_align-plugin.html" title="align-plugin">align-plugin</a></li>
                                <li class=""><a href="module_anim.html" title="anim">anim</a></li>
                                <li class=""><a href="module_arraysort.html" title="arraysort">arraysort</a></li>
                                <li class=""><a href="module_async-queue.html" title="async-queue">async-queue</a></li>
                                <li class=""><a href="module_attribute.html" title="attribute">attribute</a></li>
                                <li class=""><a href="module_autocomplete.html" title="autocomplete">autocomplete</a></li>
                                <li class=""><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_cache.html" title="cache">cache</a></li>
                                <li class=""><a href="module_charts.html" title="charts">charts</a></li>
                                <li class=""><a href="module_classnamemanager.html" title="classnamemanager">classnamemanager</a></li>
                                <li class=""><a href="module_collection.html" title="collection">collection</a></li>
                                <li class=""><a href="module_console.html" title="console">console</a></li>
                                <li class=""><a href="module_console-filters.html" title="console-filters">console-filters</a></li>
                                <li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
                                <li class=""><a href="module_dataschema.html" title="dataschema">dataschema</a></li>
                                <li class=""><a href="module_datasource.html" title="datasource">datasource</a></li>
                                <li class=""><a href="module_datatable.html" title="datatable">datatable</a></li>
                                <li class=""><a href="module_datatype.html" title="datatype">datatype</a></li>
                                <li class=""><a href="module_dd.html" title="dd">dd</a></li>
                                <li class=""><a href="module_dial.html" title="dial">dial</a></li>
                                <li class=""><a href="module_dom.html" title="dom">dom</a></li>
                                <li class=""><a href="module_dump.html" title="dump">dump</a></li>
                                <li class=""><a href="module_editor.html" title="editor">editor</a></li>
                                <li class=""><a href="module_escape.html" title="escape">escape</a></li>
                                <li class=""><a href="module_event.html" title="event">event</a></li>
                                <li class=""><a href="module_event-custom.html" title="event-custom">event-custom</a></li>
                                <li class=""><a href="module_event-gestures.html" title="event-gestures">event-gestures</a></li>
                                <li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
                                <li class=""><a href="module_event-touch.html" title="event-touch">event-touch</a></li>
                                <li class="selected"><a href="module_event-valuechange.html" title="event-valuechange">event-valuechange</a></li>
                                <li class=""><a href="module_highlight.html" title="highlight">highlight</a></li>
                                <li class=""><a href="module_history.html" title="history">history</a></li>
                                <li class=""><a href="module_history-deprecated.html" title="history-deprecated">history-deprecated</a></li>
                                <li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
                                <li class=""><a href="module_intl.html" title="intl">intl</a></li>
                                <li class=""><a href="module_io.html" title="io">io</a></li>
                                <li class=""><a href="module_json.html" title="json">json</a></li>
                                <li class=""><a href="module_jsonp.html" title="jsonp">jsonp</a></li>
                                <li class=""><a href="module_loader.html" title="loader">loader</a></li>
                                <li class=""><a href="module_node.html" title="node">node</a></li>
                                <li class=""><a href="module_node-flick.html" title="node-flick">node-flick</a></li>
                                <li class=""><a href="module_node-focusmanager.html" title="node-focusmanager">node-focusmanager</a></li>
                                <li class=""><a href="module_node-menunav.html" title="node-menunav">node-menunav</a></li>
                                <li class=""><a href="module_oop.html" title="oop">oop</a></li>
                                <li class=""><a href="module_overlay.html" title="overlay">overlay</a></li>
                                <li class=""><a href="module_plugin.html" title="plugin">plugin</a></li>
                                <li class=""><a href="module_pluginhost.html" title="pluginhost">pluginhost</a></li>
                                <li class=""><a href="module_pluginhost-base.html" title="pluginhost-base">pluginhost-base</a></li>
                                <li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
                                <li class=""><a href="module_querystring.html" title="querystring">querystring</a></li>
                                <li class=""><a href="module_queue-promote.html" title="queue-promote">queue-promote</a></li>
                                <li class=""><a href="module_recordset.html" title="recordset">recordset</a></li>
                                <li class=""><a href="module_resize.html" title="resize">resize</a></li>
                                <li class=""><a href="module_scrollview.html" title="scrollview">scrollview</a></li>
                                <li class=""><a href="module_scrollview-base.html" title="scrollview-base">scrollview-base</a></li>
                                <li class=""><a href="module_scrollview-base-ie.html" title="scrollview-base-ie">scrollview-base-ie</a></li>
                                <li class=""><a href="module_scrollview-paginator.html" title="scrollview-paginator">scrollview-paginator</a></li>
                                <li class=""><a href="module_scrollview-scrollbars.html" title="scrollview-scrollbars">scrollview-scrollbars</a></li>
                                <li class=""><a href="module_shim-plugin.html" title="shim-plugin">shim-plugin</a></li>
                                <li class=""><a href="module_slider.html" title="slider">slider</a></li>
                                <li class=""><a href="module_sortable.html" title="sortable">sortable</a></li>
                                <li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
                                <li class=""><a href="module_substitute.html" title="substitute">substitute</a></li>
                                <li class=""><a href="module_swf.html" title="swf">swf</a></li>
                                <li class=""><a href="module_swfdetect.html" title="swfdetect">swfdetect</a></li>
                                <li class=""><a href="module_tabview.html" title="tabview">tabview</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class=""><a href="module_text.html" title="text">text</a></li>
                                <li class=""><a href="module_transition.html" title="transition">transition</a></li>
                                <li class=""><a href="module_uploader.html" title="uploader">uploader</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                                <li class=""><a href="module_widget-anim.html" title="widget-anim">widget-anim</a></li>
                                <li class=""><a href="module_widget-base-ie.html" title="widget-base-ie">widget-base-ie</a></li>
                                <li class=""><a href="module_widget-child.html" title="widget-child">widget-child</a></li>
                                <li class=""><a href="module_widget-locale.html" title="widget-locale">widget-locale</a></li>
                                <li class=""><a href="module_widget-parent.html" title="widget-parent">widget-parent</a></li>
                                <li class=""><a href="module_widget-position.html" title="widget-position">widget-position</a></li>
                                <li class=""><a href="module_widget-position-align.html" title="widget-position-align">widget-position-align</a></li>
                                <li class=""><a href="module_widget-position-constrain.html" title="widget-position-constrain">widget-position-constrain</a></li>
                                <li class=""><a href="module_widget-stack.html" title="widget-stack">widget-stack</a></li>
                                <li class=""><a href="module_widget-stdmod.html" title="widget-stdmod">widget-stdmod</a></li>
                                <li class=""><a href="module_yql.html" title="yql">yql</a></li>
                                <li class=""><a href="module_yui.html" title="yui">yui</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="ValueChange.html" title="ValueChange">ValueChange</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="event-valuechange.js.html" title="event-valuechange.js">event-valuechange.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">

    var ALL_YUI_PROPS = [{"access": "protected", "host": "ValueChange", "name": "_onBlur", "url": "ValueChange.html#method__onBlur", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_onFocus", "url": "ValueChange.html#method__onFocus", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_onKeyDown", "url": "ValueChange.html#method__onKeyDown", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_onKeyUp", "url": "ValueChange.html#method__onKeyUp", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_onMouseDown", "url": "ValueChange.html#method__onMouseDown", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_onSubscribe", "url": "ValueChange.html#method__onSubscribe", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_onUnsubscribe", "url": "ValueChange.html#method__onUnsubscribe", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_poll", "url": "ValueChange.html#method__poll", "type": "method"}, {"access": "", "host": "ValueChange", "name": "POLL_INTERVAL", "url": "ValueChange.html#property_POLL_INTERVAL", "type": "property"}, {"access": "protected", "host": "ValueChange", "name": "_refreshTimeout", "url": "ValueChange.html#method__refreshTimeout", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_startPolling", "url": "ValueChange.html#method__startPolling", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_stopPolling", "url": "ValueChange.html#method__stopPolling", "type": "method"}, {"access": "protected", "host": "ValueChange", "name": "_stopTimeout", "url": "ValueChange.html#method__stopTimeout", "type": "method"}, {"access": "", "host": "ValueChange", "name": "TIMEOUT", "url": "ValueChange.html#property_TIMEOUT", "type": "property"}];
</script>
</body>
</html>
